package com.cty.controller;

import com.cty.pojo.User;
import com.cty.service.UserService;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;

import javax.annotation.Resource;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpSession;

/**
 * @Auther: cty
 * @Date: 2020/3/31 21:42
 * @Description:
 * @version: 1.0
 */
@Controller
public class UserController {
    @Resource
    private UserService userServiceImpl;

    @RequestMapping("login")
    @ResponseBody
    public String login(User user, HttpSession session){
        User userV = this.userServiceImpl.loginValidation(user);
        if(null!=userV){
            session.setAttribute("user", userV);
            return "1";
        }else {
            return "0";
        }
    }
}
